#include "StdAfx.h"
#include "cln_conn_manager.hpp"
#include "cln_connection.hpp"
#include "cln_handler.h"

namespace fly {

	namespace jld{


		namespace client {

			using namespace pool;
			class client: public boost::enable_shared_from_this<connection>,
				private boost::noncopyable
			{
			public:
				client(cln_handler* handler, size_t pool_size, const std::string& addr,const std::string& port,const size_t conn_num = 100);
				void run();
				void clean_all();
			private:

				void handle_connect(const boost::system::error_code& err, ip::tcp::resolver::iterator& endpoint_iterator);

				void ansy_connect(const boost::system::error_code& err, ip::tcp::resolver::iterator& endpoint_iterator);


				boost::asio::signal_set signals_;

				//manager client connections
				connection_manager connection_manager_;

				cln_handler* handler_;
				//new a client connection
				connection_ptr new_connection_;

				const size_t connect_number_;
			};

		}
	}
}